from rclpy.node import Node
from rcl_interfaces.msg import ParameterDescriptor
import pygame


class Settings(Node):
    """
    配置
    """
    def __init__(self, node_name):
        super().__init__(node_name=node_name)
        self._bg_color = "bg_color"
        self.declare(self._bg_color, "背景颜色", (150, 150, 150))
        self._grid_color = "grid_color"
        self.declare(self._grid_color, "格线颜色", (200, 200, 200))
        self._grid_size = "grid_size"
        self.declare(self._grid_size, "方格大小", (50, 50))

    def declare(self, name, description, default_value):
        descriptor = ParameterDescriptor(description=description)
        self.declare_parameter(name, default_value, descriptor)

    def get_bg_color(self):
        val = (
            self.get_parameter(self._bg_color).get_parameter_value().integer_array_value
        )
        return tuple(val)

    def get_grid_color(self):
        val = (
            self.get_parameter(self._grid_color)
            .get_parameter_value()
            .integer_array_value
        )
        return tuple(val)

    def get_grid_size(self):
        val = (
            self.get_parameter(self._grid_size)
            .get_parameter_value()
            .integer_array_value
        )
        return tuple(val)
